	<?php 

	error_reporting(E_ERROR);
	
	$cats = NewsCategory::model()->findAll();
	
	$all = array();
	$p = array();
	foreach($cats as $cat) {
		$all[$cat->id] =  $cat;
		$p[$cat->ParentID] = 1;
	}
	
	$o = array();
	foreach($cats as $cat) {
		if($p[$cat->id]!==1) {
			$o[] = $cat;
		}
	}

	$t = array();
	
	foreach($o as $tt) {
		$y = $tt;
		$n = '';
		$pid = -1;
		while($y) {
			if($n == '') {
				$n = $y->ClassName;
			} else
				$n = "{$y->ClassName} >" . $n;
			
			$pid = $y->ParentID;
			if($y->ParentID == 0)
				break;
			
			if($y->id == $y->ParentID) {
				break;
			}
			
			$y = $all[$y->ParentID];
		}
		
		if($pid == 0) {
			$t[$tt->id] = $n;
		}
	}
	
	?>